<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1>我是a页面</h1>
    <button class="btn">点我返回上一级页面</button>
    <button class="btn">点我跳转b页面</button>
  </body>
</html>
<script>
  var btnEle = document.getElementsByClassName("btn");
  btnEle[0].onclick = function () {
    window.history.back();
  };
  btnEle[0].onclick = function () {
    window.location.href = "./b.html";
  };
</script>
